
Partial Class Admin_Documentation_ReportsDocumentation
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        LoadReports()
    End Sub

    Private Sub LoadReports()
        Me.ReportsDataSource.ConnectionString = EntityController.AppConnectString
        Me.ReportsDataSource.SelectCommand = "Select ReportId, ReportFileName, ReportShortName, ReportLongName from Reports Order by ReportShortName"
        Me.ReportsListRepeater.DataSource = Me.ReportsDataSource.Select(System.Web.UI.DataSourceSelectArguments.Empty)
        Me.ReportsListRepeater.DataBind()
    End Sub

    Protected Sub ReportsListRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles ReportsListRepeater.ItemDataBound
        Dim grd As GridView = CType(e.Item.FindControl("RolesGridView"), GridView)
        If Not grd Is Nothing Then
            Dim grd2 As GridView = CType(e.Item.FindControl("RolesGridView2"), GridView)
            Dim rolesDS As New SqlDataSource
            Dim reportId As String = e.Item.DataItem(0)
            rolesDS.ConnectionString = EntityController.AppConnectString
            rolesDS.SelectCommand = "select r.RoleName from reportsrole rr inner join role r on rr.roleid=r.roleid  where rr.reportId=" & reportId + " order by r.RoleName"
            grd.DataSource = rolesDS.Select(System.Web.UI.DataSourceSelectArguments.Empty)
            grd.DataBind()
            grd2.DataSource = rolesDS.Select(System.Web.UI.DataSourceSelectArguments.Empty)
            grd2.DataBind()
        End If
    End Sub
End Class
